C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:43:03 PAGE 1   


C51 COMPILER V9.60.0.0, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN .\Release\main.obj
COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE main.c OPTIMIZE(0,SPEED) REGFILE(.\Release\Sample_DrvUART_Int_RX.ORC) BR
                    -OWSE INCDIR(..\..\..\..\C51SIS\C51;..\..\..\Include\Driver) DEBUG OBJECTEXTEND TABS(2) OBJECT(.\Release\main.obj)

line level    source

   1          /**************************************************************************//**
   2           * @file           main.c
   3           * @version        V1.0
   4           * $Revision:      1 $
   5           * $Date:          2017/01/04 $
   6           * @brief          Main function
   7           * @Author         Jeffrey Kang
   8           * @ContactInfo    chkang@esmt.com.tw
   9           *
  10           * @note
  11           *
  12           * Copyright (C) 1998 Elite Semiconductor Memory Technology Corp.
  13           * All rights reserved.
  14           *
  15           ******************************************************************************/
  16          
  17          
  18          #include <REG52.h>
  19          #include "system_FE81001.h"
  20          
  21          void Tx_mode();
  22          static volatile unsigned char rx_buf[10] ={0x22};
  23          static volatile unsigned char cnt = 0;
  24          
  25          bit Rx_OK = 0;
  26          
  27          
  28          /**
  29           * @brief       delay function
  30           *
  31           * @param       None
  32           *
  33           * @return      None
  34           *
  35           * @details     1. 
  36           */
  37          void delay (int cnt )
  38          {
  39   1        unsigned int i , j ;
  40   1        
  41   1        for(j=0 ; j<cnt ; j++)
  42   1        for( i = 0 ; i < 200 ; i++ ); 
  43   1        
  44   1      }
  45          
  46          
  47          /**
  48           * @brief       UARTISR function
  49           *
  50           * @param       None
  51           *
  52           * @return      None
  53           *
  54           * @details     1. 
C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:43:03 PAGE 2   

  55           */
  56          const void UARTISR (void) interrupt ISR_UART
  57          {
  58   1        unsigned char int_stat = UART->iir_fcr;
  59   1        
  60   1        if ((int_stat & 0x04) == 0x04)      //  Wait for receive data
  61   1        
  62   1        rx_buf[0] = UART->bufdat_dll;  //   Read Rx buffer 
  63   1        
  64   1        INTC->int_gmask = 0x00;  //  Disable global  interrupt
  65   1        
  66   1        Tx_mode(); //  Transfer data form Rx buffer 
  67   1        
  68   1        INTC->int_gmask = 0x01;   //  Enable global  interrupt
  69   1        
  70   1        //Rx_OK = 1;
  71   1      }
  72          
  73          
  74          /**
  75           * @brief       UARTRXConfig function
  76           *
  77           * @param       None
  78           *
  79           * @return      None
  80           *
  81           * @details     1. 
  82           */
  83          void Rx_mode()
  84          {
  85   1        /* set line control */
  86   1        UART->line_ctrl = 0x03;            // DLAB = 0, PEN = 0, STB = 0, WLS = 3
  87   1        
  88   1        /* set fifo control register */
  89   1        UART->iir_fcr = 0x01;              // RFIFOT = 0, TFIFOT = 0, DMAE = 0, TFIFORST = 0, RFIFORST = 0, FIFOE
             - = 0
  90   1        
  91   1        /* enable interrupt */
  92   1        UART->ier_dlm = 0x01;              // EMSI = 0, ELSI = 0, ETHEI = 0, ERBI = 1
  93   1        INTC->int_gmask = 0x01;            // Enable global interrupt
  94   1      }
  95          
  96          
  97          void Tx_mode()
  98          {
  99   1        
 100   1        /* set line control */
 101   1        UART->line_ctrl = 0x03;            
 102   1        
 103   1        /* set fifo control register */
 104   1        UART->iir_fcr = 0x07;              
 105   1        
 106   1        /* Loop this section to transfer more data */
 107   1        UART->bufdat_dll = rx_buf[0];
 108   1          while((UART->line_stat & 0x20) == 0x00){}  //  Wait for Tx done
 109   1      }
 110          
 111          
 112          /**
 113           * @brief       IOConfig function
 114           *
 115           * @param       None
C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:43:03 PAGE 3   

 116           *
 117           * @return      None
 118           *
 119           * @details     1. 
 120           */
 121          void IOConfig()
 122          {
 123   1        
 124   1        /* enable P0.6(RX), P0.7(TX) function */
 125   1        Set_PA6_Rx();
 126   1        Set_PA7_Tx();
 127   1        
 128   1        /* Set PA6 input, PA.7 output */
 129   1        PORT_SetPAPushPull(BIT7);
 130   1        PORT_SetPAInput(BIT6);
 131   1        
 132   1        /* Set PD1. ,PD2.,PD3 output */
 133   1        PORT_SetPDPushPull(BIT1 | BIT2 | BIT3 );
 134   1      
 135   1      }
 136          
 137          
 138          /**
 139           * @brief       CLKConfig function
 140           *
 141           * @param       None
 142           *
 143           * @return      None
 144           *
 145           * @details     1. 
 146           */
 147          void CLKConfig()
 148          {
 149   1        /* enable GPIO clock */
 150   1        PORT_PAPBPCPD_Clock_Enable();
 151   1        
 152   1        /* enable UART clock */
 153   1        En_UART_clk();
 154   1      }
 155          
 156          void UART_config()
 157          {
 158   1          CLKConfig();
 159   1          IOConfig();
 160   1        
 161   1          Set_BaudRate_115200(); /* set baud rate */
 162   1        
 163   1      }
 164          
 165          
 166          /**
 167           * @brief       main function
 168           *
 169           * @param       None
 170           *
 171           * @return      None
 172           *
 173           * @details     1. 
 174           */
 175          int main (void)
 176          {
 177   1        UART_config();
C51 COMPILER V9.60.0.0   MAIN                                                              03/16/2023 09:43:03 PAGE 4   

 178   1        Rx_mode();  
 179   1      
 180   1        PD1 = 0; // LED_G1 On
 181   1        PD3= 0;  // LED_G2  On
 182   1        
 183   1            while(1)
 184   1            {
 185   2                PD2 =  ~PD2 ; // twinkling LED_R
 186   2                delay(500); // rough 0.5s
 187   2              
 188   2            }
 189   1      }
 190          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    456    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =     18    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
